package com.woniu.day8.util;



import com.woniu.day8.interceptor.MyInterceptorHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class MyConfiguration implements WebMvcConfigurer {
    @Autowired
    private MyInterceptorHandler myInterceptorHandler;
    /**
     * 添加拦截器和拦截策略
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(myInterceptorHandler)
                .addPathPatterns("/**")        // 拦截所有请求
                .excludePathPatterns("/login","/login.html","/js/jquery-3.6.4.min.js"); // 排除不需要拦截的路径
    }
}
